//
//  CultureCell.m
//  Blank
//
//  Created by 周星宇 on 15/9/23.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "CultureCell.h"
#import <UIImageView+WebCache.h>

@implementation CultureCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backView = [[UIView alloc] init];
        self.LogoImageView = [[UIImageView alloc] init];
        self.titleLabel = [[UILabel alloc] init];
        self.dateLabel = [[UILabel alloc] init];
        self.clickLabel = [[UILabel alloc] init];
        self.nextBtn = [[UIButton alloc] init];
        [self.contentView addSubview:self.backView];
        [self.backView addSubview:self.LogoImageView];
        [self.backView addSubview:self.titleLabel];
        [self.backView addSubview:self.dateLabel];
        [self.backView addSubview:self.clickLabel];
        [self.backView addSubview:self.nextBtn];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.backView.frame = CGRectMake(5 * Windth, 10 * Height, 365 * Windth, 134 * Height);
    self.backView.layer.cornerRadius = 13;
    self.backView.layer.masksToBounds = YES;
    
    self.LogoImageView.frame = CGRectMake(17 * Windth, 17 * Height, 100 * Windth, 100 * Height);
    self.LogoImageView.layer.cornerRadius = 13;
    self.LogoImageView.layer.masksToBounds = YES;
    
    self.titleLabel.frame = CGRectMake(130 * Windth, 25 * Height, 200 * Windth, 60 * Height);
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    self.titleLabel.numberOfLines = 0;
    
    self.dateLabel.frame = CGRectMake(130 * Windth, 90 * Height, 100 * Windth, 20 * Height);
    self.dateLabel.font = [UIFont systemFontOfSize:12];
    
    self.clickLabel.frame = CGRectMake(250 * Windth, 90 * Height, 80 * Windth, 20 * Height);
    self.clickLabel.font = [UIFont systemFontOfSize:12];
    self.clickLabel.textAlignment = NSTextAlignmentRight;
    
    self.nextBtn.frame = CGRectMake(335 * Windth, 47 * Height, 20 * Windth, 40 * Height);
    
    if ([NightModel getColorModel]) {
        self.contentView.backgroundColor = [UIColor grayColor];
        self.backView.backgroundColor = [UIColor lightGrayColor];
        self.titleLabel.backgroundColor = [UIColor lightGrayColor];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.dateLabel.backgroundColor = [UIColor lightGrayColor];
        self.dateLabel.textColor = [UIColor whiteColor];
        self.clickLabel.backgroundColor = [UIColor lightGrayColor];
        self.clickLabel.textColor = [UIColor whiteColor];
    }
    else{
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.backView.backgroundColor = [UIColor colorWithRed:235 / 255.0 green:235 / 255.0 blue:242 / 255.0 alpha:0.7];
        self.titleLabel.textColor = [UIColor colorWithRed:68 / 255.0 green:136 / 255.0 blue:147 / 255.0 alpha:0.9];
        self.titleLabel.backgroundColor = [UIColor colorWithRed:235 / 255.0 green:235 / 255.0 blue:242 / 255.0 alpha:0.7];
        self.dateLabel.textColor = [UIColor colorWithRed:68 / 255.0 green:136 / 255.0 blue:147 / 255.0 alpha:0.9];
        self.dateLabel.backgroundColor = [UIColor colorWithRed:235 / 255.0 green:235 / 255.0 blue:242 / 255.0 alpha:0.7];
        self.clickLabel.textColor = [UIColor colorWithRed:68 / 255.0 green:136 / 255.0 blue:147 / 255.0 alpha:0.9];
        self.clickLabel.backgroundColor = [UIColor colorWithRed:235 / 255.0 green:235 / 255.0 blue:242 / 255.0 alpha:0.7];
    }
}

- (void)setCultureModel:(CultureModel *)cultureModel{
    [self.LogoImageView sd_setImageWithURL:[NSURL URLWithString:cultureModel.postimg] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    self.titleLabel.text = cultureModel.subject;
    self.dateLabel.text = cultureModel.postdate;
    self.clickLabel.text = [cultureModel.clicks stringByAppendingString:@"次阅读"];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
